package com.csnf.demo1.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result<T> {
    private Integer code;  // 状态码:1 表示成功，0表示失败
    private String message;  //提示信息
    private T data;

    //成功操作 且有data
    public static <T> Result<T> success(T data){
        return new Result<T>(1,"操作成功",data);
    }

    //成功操作 且无data
    public static <T> Result<T> success(){
        return new Result<T>(1,"操作成功",null);
    }

    //失败操作
    public static <T> Result<T> error(String message){
        return new Result<T>(0,message,null);
    }
}
